<?php


/**
 * 类型属性控制器
 */
class TypeAttrController extends AuthController{
	private $model;
	public function __init(){
		parent::__init();
		$this->model=K('TypeAttr');
	}
	
	/*
	 * 输出类型属性
	 * */
	public function index(){
		$tpid=Q('get.tpid',0,'intval');
		if($tpid==0) $this->error('参数错误',U('Type/index'));
		$this->assign('typeAttrData',$this->model->where("tpid={$tpid}")->all());		
		$this->display();
	}

	/*
	 * 添加属性
	 * */
	public function addAttr(){
		if(IS_POST){
			if(!$this->model->addAttr()) $this->error($this->model->error);
			$this->success('添加成功',U('index',array('tpid'=>Q('get.tpid',0,'intval'))));
		}
		$this->display();
	}

	/*
	 * 修改属性
	 * */
	public function editAttr(){
		if(IS_POST){
			if(!$this->model->editAttr()) $this->error($this->model->error);
			$this->success('修改成功',U('index',array('tpid'=>Q('get.tpid',0,'intval'))));
		}
		$tp_aid=Q('get.tp_aid',0,'intval');
		$this->assign('oldData',$this->model->where("tp_aid={$tp_aid}")->find());
		$this->display();
	}
	
	/*
	 * 删除属性
	 * */
	public function del(){
		$tp_aid=Q('get.tp_aid',0,'intval');
		$this->model->where("tp_aid={$tp_aid}")->delete();
		$this->success('删除成功');
		
	}
	 
	 
	 
	 
	 
	 
	 
	 
	 
}
    
    
    
?>

